
// index.js
// 获取应用实例
import indexImgSufix from "../../conmon/imageCommon/imageCommon"
import {getRotation,getMenu,getCommunityAnnouncement,getquestionsAnswers,getActivity,getInformation,getPropertyWorkPlan} from "../../apis/index"
const app = getApp()
Page({
  data: {
    // 导航头组件所需的参数
    isShadow:true,
    isposition:true,
    topnum:wx.getMenuButtonBoundingClientRect().top + wx.getMenuButtonBoundingClientRect().height-43,
    shop_avatar:"https://img1.baidu.com/it/u=3805829048,605031413&fm=253&fmt=auto&app=138&f=JPEG?w=749&h=500",
    nvabarData: {
      
     showCapsule: 1, //是否显示左上角图标  1表示显示  0表示不显示
     title: '标题', //导航栏 中间的标题
     white: false, // 是就显示白的，不是就显示黑的。
     address: 'https://img2.baidu.com/it/u=686428874,3063636929&fm=253&fmt=auto&app=120&f=JPEG?w=889&h=500' ,// 加个背景 不加就是没有
     images:[
      {
        "rmId": 1531248597386444800,
        "rmImageurl": "https://cdns4.91hilife.com/advertisement/other/2022/05/13/c35a720e-9ed7-47c0-a84b-d395ebab2e85.jpeg",
        "rmDescribe": "",
        "rmLink": "",
        "createTime": "2022-05-30T04:18:09.000+00:00"
      },
      {
        "rmId": 1533814654940799000,
        "rmImageurl": "https://cdns4.91hilife.com/advertisement/other/2022/05/12/f38f38a9-c9f9-4d95-b875-8fda4bbf0dd1.jpg",
        "rmDescribe": "",
        "rmLink": "",
        "createTime": "2022-06-06T14:14:45.000+00:00"
      },
      {
        "rmId": 1533814748121456600,
        "rmImageurl": "https://cdns4.91hilife.com/advertisement/other/2022/05/12/38a4ecb5-e230-4bd0-a063-ded54da8e045.jpg",
        "rmDescribe": "",
        "rmLink": "",
        "createTime": "2022-06-06T14:15:07.000+00:00"
      },
      {
        "rmId": 1533814796028797000,
        "rmImageurl": "https://cdns4.91hilife.com/advertisement/other/2022/05/12/82e4682c-a8bb-4e82-83b6-cc80c9676c64.jpg",
        "rmDescribe": "",
        "rmLink": "",
        "createTime": "2022-06-06T14:15:18.000+00:00"
      }
     ] //轮播图信息
    },
    iconimage:[ 
      {
        "hmId": 1533808735246946300,
        "hmImageurl": "http://43.138.53.237:8088/uploadImg/indeximage/more.png",
        "hmName": "更多",
        "hmLink": "pages/service/service",
        "hmDescribe": "",
        "createTime": "2022-06-06T13:51:13.000+00:00"
      }
    ],//菜单信息
    publicQAndA:[],//公开问答
    activityInfo:[],//活动信息
    marvellousLifeData:[ ],//资讯信息
    propertyWorkPlan:[]//工作计划和完成情况
  },
   onLoad:function(){
      //调用获取轮播图信息
      this.getRotations();
      //调用获取菜单信息
      this.getMenu();
      //调用获取社区公告信息
      this.getCommunityAnnouncement();
      //调用获取公开问答
      this.getquestionsAnswers();
      //调用获取社区活动信息
      this.getActivity();
      //调用获取资讯信息
      this.getInformation();
      //调用获取工作计划和完成情况
      this.getPropertyWorkPlan();
   },
  //  获取轮播图
  getRotations(){
    getRotation().then((res)=>{
      if(res.code == 200){
          this.setData({
            'nvabarData.images':res.obj
          })
      }
    })
  },
  //获取菜单
  getMenu(){
    getMenu().then((res)=>{
      if(res.code == 200){
          this.setData({
            iconimage:res.obj
          })
      }
    })
  },
  //获取社区公告
  getCommunityAnnouncement(){
    getCommunityAnnouncement(1,1).then((res)=>{
      if(res.code == 200){

      }
    })
  },
  //获取公开问答信息
  getquestionsAnswers(){
    getquestionsAnswers(1).then((res)=>{
        if(res.code == 200){
            this.setData({
              publicQAndA:res.obj
            })
        }
    })
  },
  //获取社区活动信息
  getActivity(){
    getActivity(1).then((res)=>{
      if(res.code == 200){
          this.setData({
            activityInfo:res.obj
          })
      }
    })
  },
  //获取资讯信息
  getInformation(){
    getInformation(1).then((res)=>{
      if(res.code == 200){
          this.setData({
            marvellousLifeData:res.obj
          })
      }
    })
  },
  //获取工作计划和完成情况
  getPropertyWorkPlan(){
    getPropertyWorkPlan(1).then((res)=>{
      if(res.code == 200){
          this.setData({
            propertyWorkPlan:res.obj
          })
      }
    })
  },

   toPage(e){
     const path = e.currentTarget.dataset.index;
      if(path != ''){
        wx.navigateTo({
          url: path
        })
      }
   },
   onPageScroll(e){
    
    let query = wx.createSelectorQuery();
    let that = this; 
    query.select('.custom_nav').boundingClientRect(function(rect) {
      if (e.scrollTop >  wx.getMenuButtonBoundingClientRect().top) { 
        that.setData({
          isShadow: false ,
          // isposition:false,
          // topnum:wx.getMenuButtonBoundingClientRect().to -10

        })
      } else {
        that.setData({
          isShadow: true ,
          // isposition:true,
          // topnum:90
        })
      }
    }).exec();
   },
   //页面跳转
   toWorkPlanAndCompletion(e){
     let id = e.currentTarget.dataset.pwppid;
    wx.navigateTo({
      url:'/secondary_page/workPlanAndCompletion/workPlanAndCompletion?pwppId='+id+"&commId=1"
    })
   }
})
